<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class kst_trx_poin extends MY_Controller {
	
	function __construct()
	{
		parent::__construct(); 
		
		$this->load->model('kst_trx_poin_model', 'RT');
		$this->secure_session();
	}
	
	function index(){
		$data['title'] = "Setup Trx Poin";
		viewByTemplate('kst_trx_poin/index', $data, 'grid');
	}
	 
	function getdata()
	{
		$this->secure_session();
		echo $this->RT->GetJSON();
	}

	// function dtl_sample2_data()
	// {
	// 	// Ajax Response For Datagrid
	// 	echo $this->Detail->GetJSON(post('no_detail_tagihan'));
	// }

	// function create()
	// {
	// 	// Display Form Create
	// 	$data['title'] = "Return Gudang Baru";
	// 	$data['data'] = NULL;
	// 	//$data['arr_reference']	= $this->Combo->SampleReference();
	// 	$data['mode'] = "create";
	// 	viewByTemplate('kst_return_gudang/form', $data, 'form');
	// }

	// function edit()
	// {
	// 	// Display Form Edit
	// 	$data['title'] = "Ubah Return Gudang";
	// 	$data['data'] = $this->Tagihan->GetSingleView(get('no_tagihan_listrik'));
		
	// 	// Define Combo Data
	// 	$data['mode'] = "edit";
	// 	viewByTemplate('kst_return_gudang/form', $data, 'form');
	// }
	
	// function view()
	// {
	// 	// Display Form View
	// 	$data['title'] = "View Return Gudang";
	// 	$data['data'] = $this->Tagihan->GetSingleView(get('no_tagihan_listrik'));
		
	// 	$data['mode'] = "view";
	// 	viewByTemplate('kst_return_gudang/form', $data, 'form');
	// }

	// private function validation()
	// {
	// 	$error = new ErrorList();

	// 	// Get Error Template
	// 	$tpl_empty = $this->MessageTemplate("ER001");
	// 	$tpl_duplicate = $this->MessageTemplate("ER002");
	// 	// Validation
		
	// 	if (post("no_tagihan_listrik") == '') {
	// 		$error->Add("no_tagihan_listrik", "No Tagihan Listrik", $tpl_empty);
	// 	} else if (post("mode") == "create" && intval($this->get_data("SELECT 1 FROM pro_tagihan_listrik WHERE no_tagihan_listrik = '".@ereg_replace("[^a-zA-Z0-9_-]", "",@strtoupper(@trim(post("no_tagihan_listrik"))))."'")) > 0) {
	// 		$error->Add("no_tagihan_listrik", "No Tagihan Listrik", $tpl_duplicate);
	// 	}else if (post("nama_tenant") == '') {
	// 		$error->Add("nama_tenant", "Nama Tenant", $tpl_empty);
	// 	}else if (post("no_tenant") == '') {
	// 		$error->Add("no_tenant", "No Tenant", $tpl_empty);
	// 	}

	// 	return $error;
	// }
	
	// function ajax_post()
	// {
	// 	$is_error = 0;
	// 	$ls_response = "";
	// 	$ls_genid = "";

	// 	$error = $this->validation();
	// 	try
	// 	{
	// 		if (count( $error->Get() ) > 0) { $is_error = 1; }
	// 		else
	// 		{
	// 			// Fill Post Data
	// 			$data	= post_by_key(array('no_tagihan_listrik',  'nama_tenant', 'no_tenant', 'keterangan'));
	// 			$data['no_tagihan_listrik']	= @ereg_replace("[^a-zA-Z0-9_-]", "",@strtoupper(@trim($data['no_tagihan_listrik'])));
				
	// 			if (post("mode") == "create")
	// 			{
	// 				$this->Tagihan->Add($data);

	// 				$ls_response = "Data Tersimpan";

	// 			}
	// 			else if (post("mode") == "edit")
	// 			{
					
	// 				$this->Tagihan->Update($data, array('no_tagihan_listrik'	=> $data['no_tagihan_listrik']));

	// 				$ls_response = "Data Tersimpan [edited]";
	// 			}
	// 		}


			
	// 		// ----- >> Detail Sample 2
	// 			$dtl_sample2	= $this->data['dtl_sample2'];
	// 			$total_deleted	= $dtl_sample2['num_row']['deleted'];
	// 			$total_inserted	= $dtl_sample2['num_row']['inserted'];
	// 			$total_updated	= $dtl_sample2['num_row']['updated'];
				
	// 			for($i=0,$max_i=$total_deleted; $i<$max_i; $i++){
	// 				$row = $dtl_sample2['deleted'][$i];					
	// 				$this->Detail->DeleteSingle($row['no_detail_tagihan']);
	// 			}
				
				
	// 			for($i=0,$max_i=$total_inserted; $i<$max_i; $i++){
					
	// 				// Auto number kode detail penjualan
					
					
	// 				$query = $this->db->query("SELECT no_detail_tagihan FROM (SELECT * FROM pro_dt_tagihan_sewa ORDER BY no_detail_tagihan DESC) WHERE rownum <= 1");
	// 				$getquery = $query->row_array();
	// 				$rowcount = $getquery['no_detail_tagihan'];
	// 				$autonum = $rowcount + 1;

	// 				$row = $dtl_sample2['inserted'][$i];
	// 				$row['no_detail_tagihan'] = $autonum;
	// 				$row['tanggal_pembayaran'] = $row['tanggal_pembayaran'];
	// 				$row['nama_tenant'] = $row['nama_tenant'];
	// 				$row['no_tenant'] = $row['no_tenant'];
	// 				$row['biaya_tagihan'] = $row['biaya_tagihan'];
	// 				$row['keterangan'] = $row['keterangan'];
	// 				$this->Detail->Add($row);
	// 			}
				
	// 			for($i=0,$max_i=$total_updated; $i<$max_i; $i++){
	// 				$row = $dtl_sample2['updated'][$i];					
	// 				$kode_desain	= $row['no_detail_tagihan'];
	// 				unset($row['no_detail_tagihan']);					
	// 				//$row['jumlah'] = (float)$row['jumlah'];					
	// 				$this->Detail->Update($row, array('no_detail_tagihan'	=> $no_detail_tagihan));
	// 			}
			
	// 	} catch(Exception $e) {
	// 		$is_error = 1; $ls_response = $e->getMessage();
	// 	}
		
	// 	echo $this->PostResponse(json_encode(array(	'is_error'	=> $is_error,
	// 												'fields'	=> $error->GetDictionary(),
	// 												'msg'		=> $ls_response,
	// 												'genid'		=> $ls_genid,
	// 												'form_sender'=> post("form_sender"))
	// 							));
	// }




	// function ajax_delete()
	// {
	// 	$ls_result	= "";
	// 	$no_tagihan_listrik	= get('no_tagihan_listrik');
		
	// 	if ($no_tagihan_listrik != "")
	// 	{
	// 		// Delete Single
	// 		$arr_rule	= array('no_tagihan_listrik' => $no_tagihan_listrik);
	// 		$ls_result = $this->Tagihan->DeleteSingle($arr_rule);

	// 	}
	// 	else
	// 	{
			
	// 		$num_row = intval($this->data['num_row']['deleted']);
			
	// 		for ($i = 0; $i < $num_row; $i++)
	// 		{
	// 			$row	= $this->data['deleted'][$i];
				
	// 			$arr_rule	= array('no_tagihan_listrik' => $row['no_tagihan_listrik']);
	// 			$ls_result .= $this->Tagihan->DeleteSingle($arr_rule);
	// 		}
	// 	}
		
	// 	echo $ls_result;
	// }
}
?>